// Fill out your copyright notice in the Description page of Project Settings.


#include "imageInfo.h"
#include "Engine/Engine.h"
#include "Engine/World.h"



FStoneImageInfo::FStoneImageInfo()
	: format(EOutImageFormat::JPEG)
	,width(512), height(512)
{

}
	

bool FStoneImageInfo::IsValid()const
{
	return width >= 2 && height >= 2 && format != EOutImageFormat::None;
}


FScreenshotInfo::FScreenshotInfo()
	:outImageInfo(), minimalViewInfo(), worldTargetActor(nullptr)
	, flags(EScreenshotShowFlags::Lit), ShowListOnly(false), FrameDelay(4)
	, forceAlphaToOne(true)
{

}
	
bool FScreenshotInfo::IsValid()const
{
	return outImageInfo.IsValid() && worldTargetActor != nullptr&&FrameDelay >= 1;
}

void FScreenshotInfo::Release() 
{
	ActorList.Reset();
	worldTargetActor = NULL;;
}


FImageData::FImageData() 
	:infp(), colorData(), outData()
{

}



UWorld* UimageInfoLib::GetWorldFromObj(UObject* wroldObj)
{
	if (!wroldObj)return nullptr;
	return GEngine->GetWorldFromContextObjectChecked(wroldObj);
}

EViewModeIndex UimageInfoLib::CastShowFlags(EScreenshotShowFlags showFlags)
{
	switch (showFlags)
	{
	case EScreenshotShowFlags::Lit:
		return EViewModeIndex::VMI_Lit;

	case EScreenshotShowFlags::Unlit:
		return EViewModeIndex::VMI_Unlit;
	case EScreenshotShowFlags::Wireframe:
		return EViewModeIndex::VMI_Wireframe;
	default:
		break;
	}
	return EViewModeIndex::VMI_Lit;
 }